package logic

import (
	"context"
	"encoding/json"
	"fmt"
	"github.com/hibiken/asynq"
	"t-go-zero/service/asynq/jobtype"
	"t-go-zero/service/asynq/server/internal/svc"
)

type AddHandler struct {
	svcCtx *svc.ServiceContext
}

func NewAddHandler(svcCtx *svc.ServiceContext) *AddHandler {
	return &AddHandler{
		svcCtx: svcCtx,
	}
}

func (l *AddHandler) ProcessTask(ctx context.Context, t *asynq.Task) error {
	data := t.Payload()

	var user jobtype.User

	err := json.Unmarshal(data, &user)
	if err != nil {
		fmt.Println("反序化错误")
	}

	fmt.Println(user)

	return nil
}
